import { appLocalStorage } from '@/utils/tools'
import { createSlice, PayloadAction } from '@reduxjs/toolkit'


const userInfo: any = {}

const initialUserState = {
  userInfo,
}

export const userSlice = createSlice({
  name: 'user',
  initialState: initialUserState,
  reducers: {
    updateUserInfo: (state, actions: PayloadAction<any>) => {
      appLocalStorage.setValue('userInfo', actions.payload)
      state.userInfo = actions.payload
    }
  },
})

export const userActions = userSlice.actions

export const userReducer = userSlice.reducer

export const UserType = typeof initialUserState
